package com.my.study.controller;

import com.my.study.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: yidujun
 * @create: 2021/03/23 19:58
 */
@RestController
public class MVCController {

    @Value("${server.port}")
    private String port;

    @PostMapping(value = "/globalInitBinder")
    public String globalInitBinder(@RequestParam(required = false) String name){
        System.out.println(name + "--" + port);
        return name;
    }

    @GetMapping("/xss1")
    public String xss1(@RequestParam(value = "name", required = false) String name) {
        System.out.println(name);
        return name;
    }

    @PostMapping(value = "/xss2")
    public String xss2(@RequestBody User user) {
        System.out.println(user);
        return user.toString();
    }


}
